#!/bin/bash
#
# Author:   Joshua Chen <iesugrace@gmail.com>
# Date:     2017-08-02 18:37:38
# Location: Shenzhen
# Desc: Resume the existing tasks.
#

dir_prefix=spider_
feeder="proxy_feeder/feed_proxy_db.sh"
fetcher="./fetcher.sh"
wd=$(dirname $0)
cd "$wd"

# start proxy feeder
echo "starting proxy feeder..."
$feeder resume &

# give some time for the feerder to acquire the lock
sleep 5

# start spiders
for dir in ${dir_prefix}*
do
    echo "resuming spider $dir"
    cd $dir
    $fetcher &
    cd ..
done
